import { Body, Controller, Delete, Get, Post, Put, Query } from '@nestjs/common';
import { UndergraduateService } from './undergraduate.service';

@Controller('undergraduate')
export class UndergraduateController {

    constructor(
        private readonly undergraduateService: UndergraduateService
    ) { }

    @Get()
    index(@Query() query: any) {
        return this.undergraduateService.findAll(query);
    }

    @Post('add')
    add(@Body() body: any) {
        return this.undergraduateService.add(body);
    }

    @Delete('delete')
    delete(@Body() body: any) {
        return this.undergraduateService.delete(body.id);
    }

    @Put('update')
    update(@Body() body: any) {
        return this.undergraduateService.update(body.id, body);
    }

    @Get('getUndergraduatesByCondition')
    getUndergraduatesByCondition(@Query() query: any) {
        return this.undergraduateService.getUndergraduatesByCondition(query.year, query.major_category_code);
    }
}
